#ifndef __BASE_THREAD_H__
#define __BASE_THREAD_H__

class BaseThread;
typedef void (Delegater::*OnThreadEndFunc)(BaseThread* pThread);

class BaseThread
{
public:
	BaseThread();
	virtual ~BaseThread();

	virtual void Start();
	virtual void Stop();

	bool GetStarted();

protected:
	virtual bool CheckStates();
	virtual void ThreadFunc();

	static void ThreadEntryPoint(void* pArgList);

private:
	void DoThreadEnd();

public:
	Event<OnThreadEndFunc> OnThreadEnd;

protected:
	CRITICAL_SECTION m_csThreadSafe;

	bool m_bThreadEnd;
	bool m_bStopEvent;
	bool m_bStarted;
	bool m_bTerminate;
	bool m_bModifyFlag;
};

#endif